package com.lei.design.adapter.iterator;

import java.util.Enumeration;
import java.util.Iterator;

/**
 * @Author LeiXiaoLei
 * @Date 2022/6/20 16:30
 * @Version 1.0
 */
public class ArrayListIterator<E> implements Iterator<E> {
    private final Enumeration<E> enumeration;
    public ArrayListIterator(Enumeration<E> enumeration) {
        this.enumeration = enumeration;
    }

    @Override
    public boolean hasNext() {
        return enumeration.hasMoreElements();
    }

    @Override
    public E next() {
        return enumeration.nextElement();
    }

    //Enumeration.class 不支持remove
    @Override
    public void remove() {
        throw new UnsupportedOperationException();
    }
}
